using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SmartLink.RedisRepository;

namespace SmartLink.Infrastructure.Cache
{
    /// <summary>
    /// 状态未禁用的公司缓存
    /// </summary>
    public class DisabledCompanysCache
    {
        public static bool AddDisabledCompany(int id)
        {
            return RedisManager.GetInstance().SetAsync(RedisKeyPre.DisabledCompanys, id.ToString());
        }

        public static bool AddDisabledCompanys(int[] ids)
        {
            return RedisManager.GetInstance().SetAsync(RedisKeyPre.DisabledCompanys, Array.ConvertAll(ids, id => id.ToString()));
        }

        public static List<int> GetDisabledCompanys()
        {
            return RedisManager.GetInstance().SetMembers(RedisKeyPre.DisabledCompanys).Select(a => int.Parse(a)).ToList();
        }

        public static bool RemoveDisabledCompany(int id)
        {
            return RedisManager.GetInstance().SetRemoveAsync(RedisKeyPre.DisabledCompanys, id.ToString());
        }
    }
}
